Skip to contents

Applies a formula update expression (e.g. ~ . + hp or ~ . - disp) to a model_spec object, using the same dot-notation as update.formula.

Usage

# S3 method for class 'model_spec'
update(object, formula., ...)

Arguments

object

A model_spec object.

formula.

A one-sided formula describing the update, e.g. ~ . + hp, ~ . - disp, or ~ hp (replace all terms). Use ~ . - 1 to suppress the intercept. The update applies to the main terms only: parts (see set_parts) are kept as they are, and a | is an error.

...

Unused; present for S3 generic compatibility.

Value

A new model_spec reflecting the applied update.

Examples

base_m <- model_spec(cyl, disp)
update(base_m, ~ . + hp)
#> model_spec: ~ cyl + disp + hp 
update(base_m, ~ . - disp)
#> model_spec: ~ cyl 
update(base_m, ~ . - 1)   # suppress intercept
#> model_spec: ~ 0 + cyl + disp